/*
  学习目标：React更新机制
  默认: 
    1. 父组件更新, 所有后代全部更新
    2. 组件更新, 不会导致兄弟组件更新
*/

import React, { Component } from 'react';

export default class App extends Component {
  render() {
    return (
      <div>
        <h1>App</h1>

        <Child></Child>
        <Child2></Child2>
      </div>
    );
  }
}

class Child extends React.Component {
  state = {
    count: 100,
  };

  handleAdd = () => {
    this.setState({ count: this.state.count + 1 });
  };

  render() {
    console.log('Child被触发更新了  ----->  ');
    return (
      <div>
        Child
        <button onClick={this.handleAdd}>点我+1</button>
      </div>
    );
  }
}

class Child2 extends React.Component {
  render() {
    console.log('Child2被触发更新了  ----->  ');
    return <div>Child2</div>;
  }
}
